import {FileObj} from "@/api/web/FileApi.ts";
import React from "react";
import {ViewProcessor} from "@/components/FilePreviewProcess/processors/_index.ts";
import TextView from "@/components/FilePreviewProcess/processors/TextView.tsx";
import VideoView from "@/components/FilePreviewProcess/processors/VideoView.tsx";
import TsVideoView from "@/components/FilePreviewProcess/processors/TsVideoView.tsx";
import ImageView from "@/components/FilePreviewProcess/processors/ImageView.tsx";
import AudioView from "@/components/FilePreviewProcess/processors/AudioView.tsx";

export interface ViewConf {
    fc: React.ReactNode,
    name: string,
    key: string,
}

export default (fileObj: FileObj): ViewConf[] => {
    let view: ViewConf[] = []
    let processors: ViewProcessor[] = []
    processors.push(new TextView(fileObj))
    processors.push(new VideoView(fileObj))
    processors.push(new TsVideoView(fileObj))
    processors.push(new ImageView(fileObj))
    processors.push(new AudioView(fileObj))

    for (let item of processors) {
        if (item.isViewAble()) {
            view.push({
                fc: item.ViewFunctionComponent(),
                name: item.getName(),
                key: item.getKey(),
            })
        }
    }
    return view
}
